<?php

class Admin_Model_DbTable_Origine extends Zend_Db_Table
{
    protected $_name = 'origine';
    /**
		Recuperer l'origine de l'arbre par son id
     */
    public function getOrigine($idorigine) 
    {
        $idorigine = (int)$idorigine;
        $row = $this->fetchRow('idorigine = ' . $idorigine);
        if (!$row) {
            throw new Exception("Count not find row $idorigine");
        }
        return $row->toArray();    
    }
    
    public function addOrigine($libOrigine)
    {
        $data = array(
            'libOrigine' => $libOrigine,
        );
        $this->insert($data);
    }
    
    public function updateOrigine($idorigine, $libOrigine)
    {
         $data = array(
            'libOrigine' => $libOrigine,
        );
        $this->update($data, 'idorigine = '. (int)$idorigine);
        
    }
    
    
	function deleteOrigine($idorigine) {
		$this->delete ( 'idorigine =' . ( int ) $idorigine );
	}
    /**
     * 
     * @return  
     */
    public function getAllOrigine() {    
        $all = $this->fetchAll();
        $origines = array();
     
        $origines['total'] = count($all->toArray());
        $origines['rows'] = $all->toArray();
       /* foreach ($all as $variable) {
        	$currentIndex = $variable['idfonction'] ;
        	$fonctions[$currentIndex] =$variable['libFonction'];
        }*/
        return $origines ;
    }   

 
    
   
    
}
